home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu017.dms / pu017.adf / Graphics / Example5.c < prev    next >
C/C++ Source or Header  |  1990-01-30  |  4KB  |  124 lines

  1. /* Example5                                                            */
  2. /* This program will open a normal window which is connected to the    */
  3. /* Workbench Screen. We will then draw the little nice arrow we talked */
  4. /* so much about.                                                      */
  5.  
  6.  
  7.  
  8. /* If your program is using Intuition you should include intuition.h: */
  9. #include <intuition/intuition.h>
  10.  
  11.  
  12.  
  13. struct IntuitionBase *IntuitionBase;
  14.  
  15.  
  16.  
  17. /* Declare a pointer to a Window structure: */ 
  18. struct Window *my_window;
  19.  
  20. /* Declare and initialize your NewWindow structure: */
  21. struct NewWindow my_new_window=
  22. {
  23.   40,            /* LeftEdge    x position of the window. */
  24.   20,            /* TopEdge     y positio of the window. */
  25.   100,           /* Width       100 pixels wide. */
  26.   80,            /* Height      80 lines high. */
  27.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  28.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  29.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  30.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  31.   WINDOWDRAG|    /*             Drag gadget. */
  32.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  33.   ACTIVATE,      /*             The window should be Active when opened. */
  34.   NULL,          /* FirstGadget No Custom Gadgets. */
  35.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  36.   "ARROW",       /* Title       Title of the window. */
  37.   NULL,          /* Screen      Connected to the Workbench Screen. */
  38.   NULL,          /* BitMap      No Custom BitMap. */
  39.   0,             /* MinWidth    We do not need to care about these */
  40.   0,             /* MinHeight   since we have not supplied the window */
  41.   0,             /* MaxWidth    with a Sizing Gadget. */
  42.   0,             /* MaxHeight */
  43.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  44. };
  45.  
  46.  
  47.  
  48. /* REMEMBER! Image data MUST be put in chip-memory! */
  49. USHORT chip my_image_data[]=
  50. {
  51.   0x1000, /* BitPlane ZERO */
  52.   0x3800,
  53.   0x7C00,
  54.   0xFE00,
  55.   0x1000,
  56.   0x1000,
  57.   0x1000,
  58.   0x1000
  59. };
  60.  
  61. struct Image my_image=
  62. {
  63.   45, 35,         /* LeftEdge, TopEdge. */
  64.   7,              /* Width, 7 pixels/bitts wide. */
  65.   8,              /* Height, 8 lines high. */
  66.   1,              /* Depth, only one Bitplane. */
  67.   my_image_data,  /* ImageData, pointer to my_image_data. */
  68.   0x0001,         /* PickPlane, bitplane Zero affects. */
  69.   0x0000,         /* PlaneOnOff, 0's on all other Bitplanes. */
  70.                   /* [The pixels' colour will be either 0000 (blue) or */
  71.                   /* 0001 (white).] */
  72.   NULL            /* NextImage, no more Images. */
  73. };
  74.  
  75.  
  76.  
  77. main()
  78. {
  79.   /* Open the Intuition Library: */
  80.   IntuitionBase = (struct IntuitionBase *)
  81.     OpenLibrary( "intuition.library", 0 );
  82.   
  83.   if( IntuitionBase == NULL )
  84.     exit(); /* Could NOT open the Intuition Library! */
  85.  
  86.  
  87.  
  88.   /* We will now try to open the window: */
  89.   my_window = (struct Window *) OpenWindow( &my_new_window );
  90.   
  91.   /* Have we opened the window succesfully? */
  92.   if(my_window == NULL)
  93.   {
  94.     /* Could NOT open the Window! */
  95.     
  96.     /* Close the Intuition Library since we have opened it: */
  97.     CloseLibrary( IntuitionBase );
  98.  
  99.     exit();  
  100.   }
  101.  
  102.  
  103.  
  104.   /* Tell Intuition to draw the image: */
  105.   DrawImage( my_window->RPort, &my_image, 0, 0 );
  106.  
  107.  
  108.  
  109.   /* We have opened the window, and everything seems to be OK. */
  110.   /* Wait for 30 seconds: */
  111.   Delay( 50 * 30);
  112.  
  113.  
  114.  
  115.   /* We should always close the windows we have opened before we leave: */
  116.   CloseWindow( my_window );
  117.  
  118.  
  119.   
  120.   /* Close the Intuition Library since we have opened it: */
  121.   CloseLibrary( IntuitionBase );
  122.   
  123.   /* THE END */
  124. }